package pl.edu.pw.perg.compinfodb.command;

import org.springframework.richclient.command.support.AbstractActionCommandExecutor;

import pl.edu.pw.perg.compinfodb.datamodel.IActivableModel;

public class AddNewCommandExecutor extends AbstractActionCommandExecutor 
	implements IActiveModelListener{

	private IMutableTableModel activeModel;
		
	public void setActiveModel(IActivableModel model) {
		if(model == null){
			setEnabled(false);
			return;
		}
		
		this.activeModel = (IMutableTableModel) model;
		if(activeModel.isEditable())
			setEnabled(true);
	}
	
	@Override
	public void execute() {
		activeModel.addNew();
	}


}
